<template>
  <!-- 通知弹窗 -->
  <el-popover placement="bottom" width="500" trigger="click" @show="show=true" @hide="show=false">
    <el-tabs v-model="activeName">
      <el-tab-pane label="通知" name="1">
        <MmvNotifyList :type="1" v-if="show"></MmvNotifyList>
      </el-tab-pane>
      <el-tab-pane label="公告" name="2">
        <MmvNotifyList :type="2" v-if="show"></MmvNotifyList>
      </el-tab-pane>
    </el-tabs>
    <div slot="reference">
      <div>
        <el-badge :value="magTotal" :max="99" :hidden="magTotal<1" class="item" title="公告">
          <svg-icon icon-class="dz-ms-icon" style="font-size: 24px;"/>
        </el-badge>
      </div>

    </div>
  </el-popover>
</template>

<script>
import MmvNotifyList from './components/notify-list.vue'
import * as api from "@/api/system/notice"
export default {
  name: 'MmvNotify',
  components: {
    MmvNotifyList,
  },
  data() {
    return {
      magTotal:0,
      show:false,
      activeName: '2',
    };
  },
  mounted() {
    this.getNotReadNotice();
    this.$IVue.$on('getNotReadNotice', (val)=>{
      this.getNotReadNotice();
    })
  },
  methods:{
    getNotReadNotice(){
      api.getNotReadNotice().then(res=>{
        this.magTotal=res.data
      })
    },
    close(){
      this.show=false;
      this.getNotReadNotice();
    }

  }
}
</script>
<style>
.el-badge__content.is-fixed{
  top:15px !important;
}
</style>
